<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //1.字面量创建对象
    var obj = {
        uname: '可可',
        age: 2,
        sex: '公',
        skil: function () {
            console.log('拍电影');
        }
    }
    // console.log(obj.uname);
    // console.log(obj['sex']);
    // obj.skil();

    for(var k in obj){
        console.log(k,obj[k]);
    }

    //2.new Object创建对象
    // var obj = new Object();
    // obj.uname = "可可";
    // obj.age = 2;
    // console.log(obj.age);

    //3.构造函数创建对象
    function Star(uname, age, sex) {
        this.name = uname;
        this.age = age;
        this.sex = sex;
        this.sing = function(sing){
            console.log(sing);
        }
    }
    var ldh = new Star('刘德华', 55, '男');
    console.log(ldh.name);
    console.log(ldh["sex"]);
    ldh.sing('忘情水');
    
</script>

</html>